package cn.edu.jxyy.mybatistest.test;

import cn.edu.jxyy.mybatistest.Utils.MyBatisUtils;
import cn.edu.jxyy.mybatistest.mapper.CustomerMapper;
import cn.edu.jxyy.mybatistest.pojo.Customer;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class Part14_TestIf {

    public static void main(String[] args){
        SqlSession sqlSession = MyBatisUtils.getSession();
        // 创建Customer对象，封装需要组合查询的条件
        Customer customer = new Customer();
        customer.setUsername("jack");
        customer.setJobs("teacher");

        // 执行SqlSession的查询方法，返回结果集
        CustomerMapper customerMapper =
                sqlSession.getMapper(CustomerMapper.class);
        List<Customer> customers = customerMapper.findCustomerByNameAndJobs(customer);

        // 输出查询结果信息
        for (Customer customer2 : customers) {
            // 打印输出结果
            System.out.println(customer2);
        }
        // 关闭SqlSession
        sqlSession.close();


    }
}

